from pydantic import BaseModel
from typing import Optional

class UserBase(BaseModel):
    username: str
    email: Optional[str] = None
    full_name: Optional[str] = None

class UserCreate(UserBase):
    password: str

class User(UserBase):
    id: int
    disabled: Optional[bool] = None
    
    class Config:
        from_attributes = True

class Token(BaseModel):
    access_token: str
    token_type: str

class TokenData(BaseModel):
    username: Optional[str] = None

# 身份证OCR识别相关模型
class IdCardWordItem(BaseModel):
    """身份证OCR识别结果中的单个字段"""
    words: str

class IdCardWordsResult(BaseModel):
    """身份证OCR识别结果中的words_result字段"""
    姓名: Optional[IdCardWordItem] = None
    公民身份号码: Optional[IdCardWordItem] = None
    性别: Optional[IdCardWordItem] = None
    出生: Optional[IdCardWordItem] = None
    住址: Optional[IdCardWordItem] = None
    民族: Optional[IdCardWordItem] = None

class IdCardOcrRequest(BaseModel):
    """身份证OCR识别请求体 - 直接匹配百度OCR API返回格式"""
    words_result: IdCardWordsResult

class IdCardVerifyResponse(BaseModel):
    """身份证验证响应"""
    code: int
    message: str
    data: Optional[dict] = None

